using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Collections;

using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Net.Sockets;
using BrainTechLLC;

namespace Mud.EmlenMudMain
{
    [Serializable]
    public class MemberGroup : GameThingBaseClass, IMemberGroup
    {
        public MemberGroup() { }
        private List<long> rgMstBeMemberOf = new List<long>();
        private List<long> rgCnnotBeMemberOf = new List<long>();
        private List<string> rgLders = new List<string>();
        private Dictionary<string, long> AlMemberNames = new Dictionary<string, long>(); // of NamedMudThing, value = membership level
        public List<long> rgMustBeMemberOf { get { return rgMstBeMemberOf; } set { rgMstBeMemberOf = value; } }
        public List<long> rgCannotBeMemberOf { get { return rgCnnotBeMemberOf; } set { rgCnnotBeMemberOf = value; } }
        public List<string> rgLeaders { get { return rgLders; } set { rgLders = value; } }
        public Dictionary<string, long> AllMemberNames { get { return AlMemberNames; } set { AlMemberNames = value; } }
        public bool IsMember(string memberName) { return (MembershipLevel(memberName) > 0); }
        public int MembershipLevel(string memberName)
        {
            object o = AllMemberNames[memberName.ToString()];
            if (o == null) return 0;
            return (int)o;
        }
    }

    [Serializable]
    public class GuildData : MemberGroup
    {
        public GuildData() { }
    }

    [Serializable]
    public class GuildList : EmlenMudMain.IGuildList // : MudThing
    {

        public GuildList() { }
        private List<GuildData> rgAlGuilds = new List<GuildData>();
        public List<GuildData> rgAllGuilds { get { return rgAlGuilds; } set { rgAlGuilds = value; } }
        public GuildData this[string guildName]
        {
            get
            {
                string cname = guildName;
                for (int i = 0; i < rgAllGuilds.Count; i++)
                {
                    GuildData guild = (GuildData)rgAllGuilds[i];
                    if (guild.ShortName ==  cname) return guild;
                }
                return null;
            }
        }
    }
}
// OLD CODE to PORT:

//      /*TINKER GUILD ALLOWS MEND SKILL, +1 WIS */
//      /*WARRIOR GUILD gives +1 STR +10 max HPS and FLURRY COMMAND */
//      /*HEALER GUILD gives +1 WIS and +hps on heal spells */
//      /*WIZARD GUILD gives +damage on some offensive spells and +1 INT */
//      /*RANGER GUILD gives +1 CON and makes you track at 100% */
//      /*ASSASSIN GUILD gives you +1 DEX, increases BS damage */
//      /*THIEF GUILD gives you +1 DEX, increase extraDodgeBonus */

//      /*
//         TINKER HATES ASSASSINS, WIZARDS
//         WARRIOR HATES WIZARD and HEALER and THIEF
//         HEALER HATES WIZARD and ASSASSIN and THIEF
//         WIZARD HATES HEALER and ASSASSIN and THIEF and WARRIOR
//         RANGER HATES ASSASSIN
//         ASSASSIN HATES ALL BUT WARRIOR AND THIEF
//         THIEF HATES WARRIOR, HEALER WIZARD
//       */

//      bool
//      is_member(CHAR_DATA* chr, int guildflag)
//      {
//         if (IS_MOB(chr))
//            return FALSE;
//         if (IS_SET(chr->pcdata->guilds, guildflag))
//            return TRUE;
//         else
//            return FALSE;
//      }

//      void
//      do_guild(CHAR_DATA* chr, char* szUserArguments)
//{
//  CharacterData mob;
//  char buf[STD_LENGTH];
//  DEFINE_COMMAND ("guild", do_guild, POSITION_STANDING, 0, NORMAL, "This command allows you to perform guild options at a guild house.")

//    if (IS_MOB (chr))
//    return;

//  for (mob = chr->inRoom->MoreRoomInfo->people; mob != NULL; mob = mob->next_in_room)
//    {
//      if (IS_MOB (mob) &&
//     (
//       IS_SET (mob->pIndexData->act3, ACT3_TINKER)
//       || IS_SET (mob->pIndexData->act3, ACT3_WARRIOR)
//       || IS_SET (mob->pIndexData->act3, ACT3_HEALER)
//       || IS_SET (mob->pIndexData->act3, ACT3_WIZARD)
//       || IS_SET (mob->pIndexData->act3, ACT3_THIEFG)
//       || IS_SET (mob->pIndexData->act3, ACT3_RANGER)
//       || IS_SET (mob->pIndexData->act3, ACT3_ASSASSIN)
//     )
//   )
//   break;
//    }

//  if (mob == NULL)
//    {
//      send_to_char ("There is no guildmaster present here!\n\r", chr);
//      return;
//    }
//  if (szUserArguments[0] == '\0')
//    {
//      send_to_char ("\n\rOptions:\n\r---> Guild leave\n\r---> Guild info\n\r---> Guild join\n\r---> Guild status\n\r", chr);
//      return;
//    }
//  if (!str_cmp (szUserArguments, "info"))
//    {
//      if (IS_SET (mob->pIndexData->act3, ACT3_TINKER))
//   {
//     send_to_char ("The guildmaster tells you:\n\r", chr);
//     do_help (chr, "TINKER");
//     sprintf (buf, "The Tinker's guild costs %d coins to join.  You must be level %d.\n\r", COST_TINKER, LEVEL_TINKER);
//     send_to_char (buf, chr);
//     return;
//   }
//      if (IS_SET (mob->pIndexData->act3, ACT3_WARRIOR))
//   {
//     send_to_char ("The guildmaster tells you:\n\r", chr);
//     do_help (chr, "WARRIOR");
//     sprintf (buf, "The Warrior's guild costs %d coins to join.  You must be level %d.\n\r", COST_WARRIOR, LEVEL_WARRIOR);
//     send_to_char (buf, chr);
//     return;
//   }
//      if (IS_SET (mob->pIndexData->act3, ACT3_HEALER))
//   {
//     send_to_char ("The guildmaster tells you:\n\r", chr);
//     do_help (chr, "HEALER");
//     sprintf (buf, "The Healer's guild costs %d coins to join.  You must be level %d.\n\r", COST_HEALER, LEVEL_HEALER);
//     send_to_char (buf, chr);
//     return;
//   }
//      if (IS_SET (mob->pIndexData->act3, ACT3_WIZARD))
//   {
//     send_to_char ("The guildmaster tells you:\n\r", chr);
//     do_help (chr, "WIZARD");
//     sprintf (buf, "The Wizard's guild costs %d coins to join.  You must be level %d.\n\r", COST_WIZARD, LEVEL_WIZARD);
//     send_to_char (buf, chr);
//     return;
//   }
//      if (IS_SET (mob->pIndexData->act3, ACT3_THIEFG))
//   {
//     send_to_char ("The guildmaster tells you:\n\r", chr);
//     do_help (chr, "THIEF");
//     sprintf (buf, "The Thief's guild costs %d coins to join.  You must be level %d.\n\r", COST_THIEFG, LEVEL_THIEFG);
//     send_to_char (buf, chr);
//     return;
//   }
//      if (IS_SET (mob->pIndexData->act3, ACT3_RANGER))
//   {
//     send_to_char ("The guildmaster tells you:\n\r", chr);
//     do_help (chr, "RANGER");
//     sprintf (buf, "The Ranger's guild costs %d coins to join.  You must be level %d.\n\r", COST_RANGER, LEVEL_RANGER);
//     send_to_char (buf, chr);
//     return;
//   }
//      if (IS_SET (mob->pIndexData->act3, ACT3_ASSASSIN))
//   {
//     send_to_char ("The guildmaster tells you:\n\r", chr);
//     do_help (chr, "ASSASSIN");
//     sprintf (buf, "The Assassin's guild costs %d coins to join.  You must be level %d.\n\r", COST_ASSASSIN, LEVEL_ASSASSIN);
//     send_to_char (buf, chr);
//     return;
//   }
//      return;
//    }				/*end of GUILD INFO */
//  if (!str_cmp (szUserArguments, "status"))
//    {
//      if (!IS_SET (chr->pcdata->guilds, (mob->pIndexData->act3)))
//   {
//     send_to_char ("You are not a member of our guild!\n\r", chr);
//     return;
//   }
//      send_to_char ("You are an highly respected member of the guild.\n\r", chr);
//      return;
//    }				/*end of GUILD STATUS */

//  if (!str_cmp (szUserArguments, "leave"))
//    {

//      if (!is_member (chr, (mob->pIndexData->act3)))
//   {
//     send_to_char ("You aren't even a member!!\n\r", chr);
//     return;
//   }

//      if (IS_SET (mob->pIndexData->act3, ACT3_TINKER))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Wisdom] -= 1;
//     chr->pcdata->guilds -= ACT3_TINKER;
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_WARRIOR))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Strength] -= 1;
//     chr->pcdata->guilds -= ACT3_WARRIOR;
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_HEALER))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Wisdom] -= 1;
//     chr->pcdata->guilds -= ACT3_HEALER;
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_WIZARD))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Intelligence] -= 1;
//     chr->pcdata->guilds -= ACT3_WIZARD;
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_RANGER))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Constitution] -= 1;
//     chr->pcdata->guilds -= ACT3_RANGER;
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_ASSASSIN))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Dexterity] -= 1;
//     chr->pcdata->guilds -= ACT3_ASSASSIN;
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_THIEFG))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Dexterity] -= 1;
//     chr->pcdata->guilds -= ACT3_THIEFG;
//   }
//      send_to_char ("You are no longer a member of the guild!!\n\r", chr);
//    }				/*end of GUILD LEAVE */

//  if (!str_cmp (szUserArguments, "join"))
//    {
//      int cst;
//      int lvl;

//      lvl = 0;
//      cst = 0;
//      if (IS_SET (chr->pcdata->guilds, mob->pIndexData->act3))
//   {
//     send_to_char ("You are already a member of our guild!\n\r", chr);
//     return;
//   }

//      if (IS_SET (mob->pIndexData->act3, ACT3_TINKER))
//   {
//     if (IS_SET (chr->pcdata->guilds, GUILD_ASSASSIN))
//       {
//         send_to_char ("We don't get along with Assassin's Guild scum like you.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_WIZARD))
//       {
//         send_to_char ("We will not allow rgMemberNames of the Wizard's Guild to join.\n\r", chr);
//         return;
//       }
//   }
//      if (IS_SET (mob->pIndexData->act3, ACT3_WARRIOR))
//   {
//     if (IS_SET (chr->pcdata->guilds, GUILD_HEALER))
//       {
//         send_to_char ("We don't get along with rgMemberNames of the Healer's Guild.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_WIZARD))
//       {
//         send_to_char ("We will not allow rgMemberNames of the Wizard's Guild to join.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_THIEFG))
//       {
//         send_to_char ("We don't like sneaky Thieves joining our establishment.\n\r", chr);
//         return;
//       }
//   }
//      if (IS_SET (mob->pIndexData->act3, ACT3_HEALER))
//   {
//     if (IS_SET (chr->pcdata->guilds, GUILD_ASSASSIN))
//       {
//         send_to_char ("We don't get along with rgMemberNames of the Assassin's Guild.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_WIZARD))
//       {
//         send_to_char ("We will not allow rgMemberNames of the Wizard's Guild to join.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_THIEFG))
//       {
//         send_to_char ("We don't like sneaky Thieves joining our establishment.\n\r", chr);
//         return;
//       }
//   }
//      if (IS_SET (mob->pIndexData->act3, ACT3_WIZARD))
//   {
//     if (IS_SET (chr->pcdata->guilds, GUILD_ASSASSIN))
//       {
//         send_to_char ("We don't get along with rgMemberNames of the Assassin's Guild.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_HEALER))
//       {
//         send_to_char ("We will not allow rgMemberNames of the Healer's Guild to join.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_THIEFG))
//       {
//         send_to_char ("We don't like sneaky Thieves joining our establishment.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_WARRIOR))
//       {
//         send_to_char ("We don't like rgMemberNames of the Warrior's Guild joining our fine establishment.\n\r", chr);
//         return;
//       }
//   }
//      if (IS_SET (mob->pIndexData->act3, ACT3_RANGER))
//   {
//     if (IS_SET (chr->pcdata->guilds, GUILD_ASSASSIN))
//       {
//         send_to_char ("We don't get along with rgMemberNames of the Assassin's Guild.\n\r", chr);
//         return;
//       }
//   }
//      if (IS_SET (mob->pIndexData->act3, ACT3_ASSASSIN))
//   {
//     if (IS_SET (chr->pcdata->guilds, GUILD_WIZARD))
//       {
//         send_to_char ("We detest rgMemberNames of the Wizard's Guild.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_HEALER))
//       {
//         send_to_char ("We will not allow rgMemberNames of the Healer's Guild to join.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_TINKER))
//       {
//         send_to_char ("We don't like brainless tinkers joining our establishment.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_RANGER))
//       {
//         send_to_char ("We don't like rgMemberNames of the Ranger's Guild joining our secret guild.\n\r", chr);
//         return;
//       }
//   }
//      if (IS_SET (mob->pIndexData->act3, ACT3_THIEFG))
//   {
//     if (IS_SET (chr->pcdata->guilds, GUILD_WARRIOR))
//       {
//         send_to_char ("We don't get along with rgMemberNames of the Warrior's Guild.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_WIZARD))
//       {
//         send_to_char ("We will not allow rgMemberNames of the Wizard's Guild to join.\n\r", chr);
//         return;
//       }
//     if (IS_SET (chr->pcdata->guilds, GUILD_HEALER))
//       {
//         send_to_char ("We don't allow rgMemberNames of the Healer's Guild to join our establishment.\n\r", chr);
//         return;
//       }
//   }


//      if (IS_SET (mob->pIndexData->act3, ACT3_TINKER))
//   {
//     cst = COST_TINKER;
//     lvl = LEVEL_TINKER;
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_WARRIOR))
//   {
//     cst = COST_WARRIOR;
//     lvl = LEVEL_WARRIOR;
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_HEALER))
//   {
//     cst = COST_HEALER;
//     lvl = LEVEL_HEALER;
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_WIZARD))
//   {
//     cst = COST_WIZARD;
//     lvl = LEVEL_WIZARD;
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_RANGER))
//   {
//     cst = COST_RANGER;
//     lvl = LEVEL_RANGER;
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_ASSASSIN))
//   {
//     cst = COST_ASSASSIN;
//     lvl = LEVEL_ASSASSIN;
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_THIEFG))
//   {
//     cst = COST_THIEFG;
//     lvl = LEVEL_THIEFG;
//   }

//      if (LEVEL (chr) < lvl)
//   {
//     sprintf (buf, "You need to be level %d to join the guild!\n\r", lvl);
//     send_to_char (buf, chr);
//     return;
//   }
//      if (tally_coins (chr) < cst)
//   {
//     sprintf (buf, "We need a payment of %d coins before we can let you join.\n\r", cst);
//     send_to_char (buf, chr);
//     return;
//   }

//      sub_coins (cst, chr);
//      if (IS_SET (mob->pIndexData->act3, ACT3_TINKER))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Wisdom] += 1;
//     chr->pcdata->guilds += ACT3_TINKER;
//     send_to_char ("Congratulations!  You are now a member of the Tinker's Guild!\n\r", chr);
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_WARRIOR))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Strength] += 1;
//     chr->pcdata->guilds += (mob->pIndexData->act3);
//     send_to_char ("Congratulations!  You are now a member of the Warrior's Guild!\n\r", chr);
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_HEALER))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Wisdom] += 1;
//     chr->pcdata->guilds += ACT3_HEALER;
//     send_to_char ("Congratulations!  You are now a member of the Healer's Guild!\n\r", chr);
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_WIZARD))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Intelligence] += 1;
//     chr->pcdata->guilds += ACT3_WIZARD;
//     send_to_char ("Congratulations!  You are now a member of the Wizard's Guild!\n\r", chr);
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_RANGER))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Constitution] += 1;
//     chr->pcdata->guilds += ACT3_RANGER;
//     send_to_char ("Congratulations!  You are now a member of the Ranger's Guild!\n\r", chr);
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_ASSASSIN))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Dexterity] += 1;
//     chr->pcdata->guilds += ACT3_ASSASSIN;
//     send_to_char ("Congratulations!  You are now a member of the Assassin's Guild!\n\r", chr);
//   }
//      else if (IS_SET (mob->pIndexData->act3, ACT3_THIEFG))
//   {
//     chr->pcdata->PermanentStats[StatTypes.Dexterity] += 1;
//     chr->pcdata->guilds += ACT3_THIEFG;
//     send_to_char ("Congratulations!  You are now a member of the Thief's Guild!\n\r", chr);
//   }
//      sprintf (buf, "Welcome to our guild, %s!", NAME (chr));
//      do_say (mob, buf);



//    }				/*end of GUILD JOIN */

//  return;
//}

